package p_01;

public class Pair<G extends Comparable<G>, H extends Comparable<H>> implements Comparable<Pair<G, H>>
{
  private G first;
  private H second;
  
  public Pair()
  {
    this.first = null;
    this.second = null;
  }
  
  public Pair(G first, H second)
  {
    this.first = first;
    this.second = second;
  }
  
  public G getFirst()
  {
    return first;
  }
  
  public void setFirst(G first)
  {
    this.first = first;
  }
  
  public H getSecond()
  {
    return second;
  }
  
  public void setSecond(H second)
  {
    this.second = second;
  }
   
  public int compareTo(Pair<G, H> other)
  {
    int result = first.compareTo(other.first);
    if (result == 0)
      result = second.compareTo(other.second);
    return result;
  }
  
  public String toString()
  {
    return first.toString() + " " + second.toString();
  }
}
